/////////////////////////////////////////////////////////////////////////////
// Original code from libhdfs3. Copyright (c) 2013 - 2014, Pivotal Inc.
// All rights reserved. Author: Zhanwei Wang
/////////////////////////////////////////////////////////////////////////////
//  Modifications by Kumo Inc.
// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//



#pragma once

#include <kmock/kmock.h>

#include <kmhdfs/client/directory_iterator.h>
#include <kmhdfs/client/file_status.h>
#include <kmhdfs/client/file_system.h>
#include <kmhdfs/client/file_system_inter.h>
#include <kmhdfs/client/file_system_key.h>
#include <kmhdfs/client/file_system_stats.h>
#include <kmhdfs/client/permission.h>
#include <kmhdfs/client/user_info.h>
#include <memory>
#include <kmhdfs/server/datanode_info.h>
#include <kmhdfs/server/extended_block.h>
#include <kmhdfs/server/located_block.h>
#include <kmhdfs/server/located_blocks.h>
#include <kmhdfs/common/session_config.h>

#include <string>
#include <vector>

class MockFileSystemInter: public Hdfs::Internal::FileSystemInter {
public:
  MOCK_METHOD0(connect, void());
  MOCK_METHOD0(disconnect, void());
  MOCK_METHOD1(getStandardPath, const std::string(const char * path));
  MOCK_METHOD0(getClientName, const char *());
  MOCK_CONST_METHOD0(getDefaultReplication, int());
  MOCK_CONST_METHOD0(getDefaultBlockSize, int64_t());
  MOCK_CONST_METHOD0(getHomeDirectory, std::string());
  MOCK_METHOD2(deletePath, bool(const char * path, bool recursive));
  MOCK_METHOD2(mkdir, bool(const char * path, const Hdfs::Permission & permission));
  MOCK_METHOD2(mkdirs, bool(const char * path, const Hdfs::Permission & permission));
  MOCK_METHOD1(getFileStatus, Hdfs::FileStatus(const char * path));
  MOCK_METHOD3(setOwner, void(const char * path, const char * username, const char * groupname));
  MOCK_METHOD3(setTimes, void(const char * path, int64_t mtime, int64_t atime));
  MOCK_METHOD2(setPermission, void(const char * path, const Hdfs::Permission &));
  MOCK_METHOD2(setReplication, bool(const char * path, short replication));
  MOCK_METHOD2(rename, bool(const char * src, const char * dst));
  MOCK_METHOD1(setWorkingDirectory, void(const char * path));
  MOCK_CONST_METHOD0(getWorkingDirectory, std::string());
  MOCK_METHOD1(exist, bool(const char * path));
  MOCK_METHOD0(getFsStats, Hdfs::FileSystemStats());
  MOCK_METHOD2(truncate, bool(const char * src, int64_t size));
  MOCK_METHOD1(getDelegationToken, std::string(const char * renewer));
  MOCK_METHOD0(getDelegationToken, std::string());
  MOCK_METHOD1(renewDelegationToken, int64_t(const std::string & token));
  MOCK_METHOD1(cancelDelegationToken, void(const std::string & token));
  MOCK_METHOD6(create, Hdfs::FileStatus(const std::string & src, const Hdfs::Permission & masked, int flag, bool createParent, short replication, int64_t blockSize));
  MOCK_METHOD2(append, std::pair<std::shared_ptr<Hdfs::Internal::LocatedBlock>,
               std::shared_ptr<Hdfs::FileStatus> >(const std::string & src, const uint32_t & flag));
  MOCK_METHOD3(abandonBlock, void(const Hdfs::Internal::ExtendedBlock & b, const std::string & srcr, int64_t fileId));
  MOCK_METHOD4(addBlock, std::shared_ptr<Hdfs::Internal::LocatedBlock>(const std::string & src,
          const Hdfs::Internal::ExtendedBlock * previous,
          const std::vector<Hdfs::Internal::DatanodeInfo> & excludeNodes, int64_t fileId));
  MOCK_METHOD6(getAdditionalDatanode, std::shared_ptr<Hdfs::Internal::LocatedBlock> (const std::string & src,
          const Hdfs::Internal::ExtendedBlock & blk,
          const std::vector<Hdfs::Internal::DatanodeInfo> & existings,
          const std::vector<std::string> & storageIDs,
          const std::vector<Hdfs::Internal::DatanodeInfo> & excludes, int numAdditionalNodes));
  MOCK_METHOD3(complete, bool(const std::string & src,
          const Hdfs::Internal::ExtendedBlock * last, int64_t fileId));
  MOCK_METHOD1(reportBadBlocks, void(const std::vector<Hdfs::Internal::LocatedBlock> & blocks));
  MOCK_METHOD1(fsync, void(const std::string & src));
  MOCK_METHOD1(updateBlockForPipeline, std::shared_ptr<Hdfs::Internal::LocatedBlock>(const Hdfs::Internal::ExtendedBlock & block));
  MOCK_METHOD4(updatePipeline, void(const Hdfs::Internal::ExtendedBlock & oldBlock,
          const Hdfs::Internal::ExtendedBlock & newBlock,
          const std::vector<Hdfs::Internal::DatanodeInfo> & newNodes,
          const std::vector<std::string> & storageIDs));
  MOCK_CONST_METHOD0(getConf, const Hdfs::Internal::SessionConfig &());
  MOCK_CONST_METHOD0(getUserInfo, const Hdfs::Internal::UserInfo &());
  MOCK_METHOD4(getBlockLocations, void(const std::string & src, int64_t offset, int64_t length, Hdfs::Internal::LocatedBlocks & lbs));
  MOCK_METHOD4(getListing, bool(const std::string & src, const std::string & , bool needLocation, std::vector<Hdfs::FileStatus> &));
  MOCK_METHOD2(listDirectory, Hdfs::DirectoryIterator(const char *, bool));
  MOCK_METHOD0(renewLease, bool());
  MOCK_METHOD0(registerOpenedOutputStream, void());
  MOCK_METHOD0(unregisterOpenedOutputStream, bool());
  MOCK_METHOD3(getFileBlockLocations, std::vector<Hdfs::BlockLocation> (const char * path, int64_t start, int64_t len));
  MOCK_METHOD2(listAllDirectoryItems, std::vector<Hdfs::FileStatus> (const char * path, bool needLocation));
  MOCK_METHOD0(getPeerCache, Hdfs::Internal::PeerCache &());
};
